﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
using BaseTypesLib.Model;

namespace BaseTypesLib.Converters
{
    [ValueConversion(typeof(FieldVerticalAlignment), typeof(VerticalAlignment))]
    public class VerticalAlignmentConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FieldVerticalAlignment alignment = (FieldVerticalAlignment)value;
            switch (alignment)
            {
                case FieldVerticalAlignment.Center: return VerticalAlignment.Center;
                case FieldVerticalAlignment.Top: return VerticalAlignment.Top;
                case FieldVerticalAlignment.Bottom: return VerticalAlignment.Bottom;
                default: return FieldVerticalAlignment.Top;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            VerticalAlignment alignment = (VerticalAlignment)value;
            switch (alignment)
            {
                case VerticalAlignment.Center: return FieldVerticalAlignment.Center;
                case VerticalAlignment.Top: return FieldVerticalAlignment.Top;
                case VerticalAlignment.Bottom: return FieldVerticalAlignment.Bottom;
                default: return FieldVerticalAlignment.Top;
            }
        }
    }
}
